package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class StrategyDetail extends BaseDomain{
    //标题
    private String title;
    //创建时间
    private Date createTime;
    //发布时间
    private Date releaseTime;
    //序号
    private Integer sequence;
    //攻略类型
    private StrategyCatalog catalog;
    //封面
    private String coverUrl;
    //状态,是否发布
    private Boolean state;

    private StrategyContent strategyContent;

    public String getStateName(){
        String temp = "草稿";
        if (state) {
            temp = "发布";
        }
        return temp;
    }

    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("title",title);
        map.put("createTime",createTime);
        map.put("releaseTime",releaseTime);
        map.put("sequence",sequence);
        map.put("coverUrl",coverUrl);
        map.put("state",state);
        if (catalog != null) {
            map.put("strategyCatalogId",catalog.getId());
            map.put("strategyCatalogName",catalog.getName());
            if (catalog.getStrategy() != null) {
                map.put("strategyId",catalog.getStrategy().getId());
            }
        }
        return JSONUtil.toJSONString(map);
    }

}